From: Arianna Avanzini Date: Sat, 30 Aug 2014 16:29:36 +0000 (+0200) Subject: arch/arm: add consistency check to REMOVE p2m changes X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4493 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=2add6eaf5b66f558d711d28c9cb5761eae2d1368;p=xen.git arch/arm: add consistency check to REMOVE p2m changes Currently, the REMOVE case of the switch in apply_p2m_changes() does not perform any consistency check on the mapping to be removed. More in detail, the code does not check if the guest address to be unmapped is actually mapped to the machine address given as a parameter. This commit adds the above-described consistency check to the REMOVE path of apply_p2m_changes() and lets a warning be emitted when trying to remove a non-existent mapping. This is instrumental to one of the following commits, which implements the possibility to trigger the removal of p2m ranges via the memory_mapping DOMCTL for ARM. Signed-off-by: Arianna Avanzini Acked-by: Stefano Stabellini Reviewed-by: Julien Grall Cc: Dario Faggioli Cc: Paolo Valente Cc: Ian Campbell Cc: Jan Beulich Cc: Keir Fraser Cc: Tim Deegan Cc: Ian Jackson Cc: Andrew Cooper Cc: Eric Trudeau Cc: Viktor Kleinik Cc: Andrii Tseglytskyi Acked-by: Ian Campbell --- diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 143199bdf5..8f83d17df2 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -601,6 +601,7 @@ static int apply_one_level(struct domain *d, { /* Progress up to next boundary */ *addr = (*addr + level_size) & level_mask; + *maddr = (*maddr + level_size) & level_mask; return P2M_ONE_PROGRESS_NOP; } @@ -632,12 +633,29 @@ static int apply_one_level(struct domain *d, } } + /* + * Ensure that the guest address addr currently being + * handled (that is in the range given as argument to + * this function) is actually mapped to the corresponding + * machine address in the specified range. maddr here is + * the machine address given to the function, while + * orig_pte.p2m.base is the machine frame number actually + * mapped to the guest address: check if the two correspond. + */ + if ( op == REMOVE && + pfn_to_paddr(orig_pte.p2m.base) != *maddr ) + printk(XENLOG_G_WARNING + "p2m_remove dom%d: mapping at %"PRIpaddr" is of maddr %"PRIpaddr" not %"PRIpaddr" as expected\n", + d->domain_id, *addr, pfn_to_paddr(orig_pte.p2m.base), + *maddr); + *flush = true; memset(&pte, 0x00, sizeof(pte)); p2m_write_pte(entry, pte, flush_cache); *addr += level_size; + *maddr += level_size; p2m->stats.mappings[level]--;